package router

import (
	"github.com/gin-gonic/gin"
	"wrblog-api-go/demo/api/demo/api_docker"
	"wrblog-api-go/demo/api/demo/api_rabbit"
	"wrblog-api-go/demo/modules/socket"
	"wrblog-api-go/pkg/request"
)

func ApiDemo(apiV1 *gin.RouterGroup) {
	demoApi := apiV1.Group("/demo")
	{
		socketApi := demoApi.Group("/socket")
		{
			socketApi.GET("/open", socket.WebsocketHandler)
		}
		rabbitApi := demoApi.Group("/rabbit")
		{
			rabbitApi.GET("/start", api_rabbit.Start)
			rabbitApi.POST("/push", api_rabbit.PushData)
		}
		dockerApi := demoApi.Group("/docker")
		{
			// containers
			dockerApi.GET("/containers", api_docker.ListContainers)
			dockerApi.POST("/containers", request.BindAllStruct[api_docker.CreateContainerReq](), api_docker.CreateContainer)
			dockerApi.POST("/containers/:id/start", api_docker.StartContainer)
			dockerApi.POST("/containers/:id/stop", api_docker.StopContainer)
			dockerApi.DELETE("/containers/:id", api_docker.RemoveContainer)
			dockerApi.GET("/containers/:id/logs", api_docker.ContainerLogs)

			// images
			dockerApi.GET("/images", api_docker.ListImages)
			dockerApi.POST("/images/pull", request.BindAllStruct[api_docker.PullImageReq](), api_docker.PullImage)
		}
	}

}
